const app = getApp()
//初始化数据
function tabbarinit(userType) {
  return [
      {
      "pagePath": userType == '1' ? "/pages/index/judge/index" : "/pages/index/people/index",
        "text": "首页",
        "iconPath": "/static/images/tabbar/home.png",
        "selectedIconPath": "/static/images/tabbar/home_select.png",
        "selectedColor": "#4665f9"
      },
      {
        "pagePath": "/pages/users/index",
        "text": "我的",
        "iconPath": "/static/images/tabbar/me.png",
        "selectedIconPath": "/static/images/tabbar/me_select.png",
        "selectedColor": "#4665f9"
      }
  ]
}

/**
 * tabbar主入口
 * @param  {String} bindName 
 * @param  {[type]} id       [表示第几个tabbar，以0开始]
 * @param  {[type]} target   [当前对象]
 */
function tabbarmain(bindName = "tabdata", id, target , userType) {
  var that = target;
  var bindData = {};
  var otabbar = tabbarinit(userType)
  otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon
  otabbar[id]['current'] = 1;
  bindData[bindName] = otabbar
  that.setData({ bindData });
}
module.exports = {
  tabbar: tabbarmain
}